local danming = fk.CreateSkill{
  name = "xiaobai__danming",
}
danming:addEffect(fk.CardUseFinished,  {  anim_type = "drawcard",
  events = {fk.CardUseFinished},
  can_trigger = function (self, event, target, player, data)
    return player:hasSkill(self) and player:getHandcardNum() ~= 4 - player:getMark("@xiaobai__danming_reduce-round") and target == player
  end,
  on_cost = function (self, event, target, player, data)
    return player.room:askToSkillInvoke(player, {
      skill_name = danming.name,
      prompt = "#xiaobai__danming-use:::"..(4-player:getMark("@xiaobai__danming_reduce-round"))
    })
  end,
  on_use = function (self, event, target, player, data)
    local room = player.room
    local num = 4- player:getMark("@xiaobai__danming_reduce-round") - player:getHandcardNum()
    if num > 0 then
      player:drawCards(num,danming.name)
      if player.dead then return end
      if player:getMark("@xiaobai__danming_reduce-round") < 4 and room:askToSkillInvoke(player, {
        skill_name = danming.name,
        prompt = "#xiaobai__danming-continue"}) then
        room:addPlayerMark(player, "@xiaobai__danming_reduce-round",1)
      else
        room:delay(200)
        room:invalidateSkill(player, danming.name,"-turn")
        room:addPlayerMark(player, "@@xiaobai__danming-invalid-turn")
      end
    else
      room:askToDiscard(player, {
        min_num = -num,
        max_num = -num,
        include_equip = false,
        skill_name = danming.name
      })
    end
  end
})

Fk:loadTranslationTable{
  ["xiaobai__danming"] = "耽名",
  ["#xiaobai__danming-use"] = "耽名：你可以将手牌调整至%arg张",
  ["#xiaobai__danming-continue"] = "耽名：你可以令此技能数值本轮-1，或点“取消”令本回合此技能失效。",
  [":xiaobai__danming"] = "你使用一张牌后，可将手牌数调整至4，若因此摸牌，你选择一项：1、令此数值-1直至本轮结束。2、本回合此技能失效。",
  ["@xiaobai__danming_reduce-round"] = "耽名减少",
  ["@@xiaobai__danming-invalid-turn"] = "耽名失效",

  ["$xiaobai__danming1"] = "吾欲播名天下，当以才智示人。",
  ["$xiaobai__danming2"] = "君子矜于风姿，虽颓亦可登名。",
}

return danming